import java.util.*;

public class Main{
    /**
     * NC223985 小红无敌
     * https://ac.nowcoder.com/acm/problem/223985
     * @param args
     */
    public static void main1(String[] args){
        Scanner in = new Scanner(System.in);

        long a = in.nextLong(),h = in.nextLong(),b = in.nextLong(),k = in.nextLong();

        //1.计算互砍的次数
        long n = Math.min(h / b,k /a);

        h = h - n * b;
        k = k - n * a;

        long ret = n * (a + b);

        //2.判断是否存活
        if(h > 0 && k > 0){
            h -= b;
            k -= a;
            ret += a + b;
        }

        //是否释放大招
        if(h > 0 || k > 0){
            ret += 10 * (h > 0 ? a : b);
        }

        System.out.println(ret);
    }

    /**
     * 连续子区间最大值
     * DP6 https://www.nowcoder.com/practice/1718131e719746e9a56fb29c40cc8f95?tpId=230&tqId=39753&ru=/exam/oj
     * @param args
     */
    public static void main2(String[] args)
    {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long max = -(int)1e9;
        long[] dp = new long[n + 1];
        for(int i = 1;i <= n;i++)
        {
            int x = in.nextInt();
            dp[i] = Math.max(dp[i - 1] + x ,x);
            max = Math.max(dp[i],max);
        }

        System.out.println(max);

    }

    /**
     * NC214851 非对称美
     * https://ac.nowcoder.com/acm/problem/214851
     */
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        char[] s = in.nextLine().toCharArray();

        int len = s.length;
        boolean flag = false;//默认是同一个字符

        for(int i = 1;i < len;i++){
            if(s[i] != s[i - 1])
            {
                flag = true;
                break;
            }
        }

        if(flag){
            int left = 0,right = len - 1;
            while(left < right){
                if(s[left] != s[right]){
                    flag = false;
                    break;
                }else{
                    left++;
                    right--;
                }
            }
            if(!flag) System.out.println(len);
            else System.out.println(len - 1);
        }else{
            System.out.println(0);
        }
    }
}